package com.hengpeng.itfin.job;

import java.util.Date;

import com.hengpeng.common.cis.ComponentContextLoader;
import com.hengpeng.common.scheduling.AbstractJob;
import com.hengpeng.common.scheduling.ScheduleConfig;
import com.hengpeng.common.util.DateTimeUtil;
import com.hengpeng.itfin.service.ServiceFactory;

/**
 * <pre>
 * 放款对账定时作业
 * </pre>
 * 
 * @author weiyuan
 * @version 1.0, 2015年7月19日
 */
public class LoansReconciliationJob extends AbstractJob {
    private final static int pageSize = 50;// 每页显示记录数量

    private final static int dayRangeForward = -5;// 向前查询范围

    private final static int dayRangeBack = 5;// 向后查询范围

    private final static int initPageNum = 1;// 初始页数

    @Override
    public void exec(boolean isTimeout, ScheduleConfig config) {
        log.info("放款对账定时作业开始,时间：" + DateTimeUtil.formatToStr(new Date(), DateTimeUtil.DATE_FORMAT_YMDHMS));
        ServiceFactory serviceFactory = ComponentContextLoader.getBean(ServiceFactory.class);
        Date beginDate = DateTimeUtil.addDate(new Date(), dayRangeForward);
        Date endDate = DateTimeUtil.addDate(new Date(), dayRangeBack);
        serviceFactory.getBorrowService().loansReconciliation(initPageNum, pageSize, beginDate, endDate);
        log.info("放款对账定时作业结束,时间：" + DateTimeUtil.formatToStr(new Date(), DateTimeUtil.DATE_FORMAT_YMDHMS));
    }

    public static void main(String[] args) {
        LoansReconciliationJob job = new LoansReconciliationJob();
        job.exec(false, null);
    }
}
